﻿Imports System.Threading
Imports System.Globalization

Public Class AppOptionForm
    Private _dataTableLocal As DataTable
    Private _dataTableAdmin As DataTable
    Private _aMetaQuery As CommonExt.MetaQuery

    'Identifier les Query que le code a besoin pour populer les controles
    '
    Const Query_DefaultSociety As String = "LOV_LocalOption_DefaultSociety"
    Const Query_SessionSociety As String = "LOV_LocalOption_SessionSociety"
    Const Query_PrmAlt As String = ""
    Const Query_Language As String = "LOV_LocalOption_Language"

    ' Query qui donne la liste de tous les GUID par défaut de l'écran (MetaApplicationOption / MetaUserOption) se fait dans la query seul...
    ''
    Const Query_LocalOption As String = "LocalOption"
    Const Query_AdminOption As String = "AdminOption"


    ' Definis des champs pour récupéré le GUID du MetaUserOption sur quoi on doit faire le Insert/Update
    '
    Dim aCulture As String = "en-US"
    Dim keys(1) As DataColumn
    Dim PersonOptionID_DefaultSociety As Guid
    Dim PersonOptionID_SessionSociety As Guid
    Dim PersonOptionID_Description As Guid
    Dim PersonOptionID_Language As Guid
    Dim PersonOptionID_DecimalSeparator As Guid
    Dim PersonOptionID_ThousandsSeparator As Guid

    Public Sub New()

        '' This call is required by the designer.
        '' Set the culture and UI culture before 
        '' the call to InitializeComponent.
        'Dim aculture As String = New AppOption().Culture
        'Thread.CurrentThread.CurrentCulture = New CultureInfo(aculture)
        'Thread.CurrentThread.CurrentUICulture = New CultureInfo(aculture)

        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        init()
    End Sub

    Public Sub init()

        '
        ' ADMIN TAB
        '
        ' Copy Current Security To New Security File
        '


        TextEditUserName.Text = AppManager.UserName
        TextEditServer.Text = AppManager.DbServerName
        TextEditDB.Text = AppManager.DbName

        '
        ' GENERAL TAB

        'Récupere la liste des MEtaApplicationOptions ainsi que la valeur par défaut (soit setter dans MetaApplicationOption / soit dans MetaUserOption)
        '
        ' Information Local Users
        _aMetaQuery = MetaQuery.GetMetaQueryByName(Query_LocalOption)
        _aMetaQuery.SQLFrom += String.Format(" and MetaUserOptions.UserId_FK = '{{{0}}}'", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
        _aMetaQuery.FillResultQuery()
        _dataTableLocal = _aMetaQuery.ResultQuery
        'Définie la Clé de recherche...
        keys(0) = _dataTableLocal.Columns("AppOptionId")
        'Set la clé de recherche....
        _dataTableLocal.PrimaryKey = keys

        'Information Admin User
        _aMetaQuery = MetaQuery.GetMetaQueryByName(Query_AdminOption)
        _aMetaQuery.FillResultQuery()
        _dataTableAdmin = _aMetaQuery.ResultQuery
        'Définie la Clé de recherche...
        keys(0) = _dataTableAdmin.Columns("AppOptionId")
        'Set la clé de recherche....
        _dataTableAdmin.PrimaryKey = keys

        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        Dim aLanguageID As System.Guid = New Guid(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_LANGUAGE).Item("OptionValue").ToString)

        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_LANGUAGE).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_Language = Guid.NewGuid()
        Else
            PersonOptionID_Language = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_LANGUAGE).Item("PersonOptionID"), Guid)
        End If





        '
        ' Polulate Default Society
        '

        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DEFAULTSOCIETY).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_DefaultSociety = Guid.NewGuid()
        Else
            PersonOptionID_DefaultSociety = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DEFAULTSOCIETY).Item("PersonOptionID"), Guid)
        End If

        _aMetaQuery = MetaQuery.GetMetaQueryByName(Query_DefaultSociety)
        _aMetaQuery.FillResultQuery()
        GridLookUpEditDefaultSociety.Properties.DataSource = _aMetaQuery.ResultQuery
        GridLookUpEditDefaultSociety.Properties.PopulateViewColumns()
        GridLookUpEditDefaultSociety.Properties.NullText = "(none)"
        GridLookUpEditDefaultSociety.Properties.ValueMember = _aMetaQuery.ResultQuery.Columns("SocietyId").ToString
        GridLookUpEditDefaultSociety.Properties.PopupFormSize = New Size(500, 300)
        GridLookUpEditDefaultSociety.Properties.DisplayMember = _aMetaQuery.ResultQuery.Columns("SocietyName").ToString
        GridLookUpEditDefaultSociety.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit
        GridLookUpEditDefaultSociety.Properties.View.Columns("SocietyId").Visible = False
        ' Select the good ROW in ComboBox
        Dim aGUID As System.Guid = New System.Guid

        If Guid.TryParse(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DEFAULTSOCIETY).Item("OptionValue").ToString, aGUID) Then
            GridLookUpEditDefaultSociety.EditValue = aGUID
        End If

        '
        ' Polulate Session Society
        '
        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_SESSIONSOCIETY).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_SessionSociety = Guid.NewGuid()
        Else
            PersonOptionID_SessionSociety = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_SESSIONSOCIETY).Item("PersonOptionID"), Guid)
        End If

        _aMetaQuery = CommonExt.MetaQuery.GetMetaQueryByName(Query_SessionSociety)
        _aMetaQuery.FillResultQuery()
        GridLookUpEditSessionSociety.Properties.DataSource = _aMetaQuery.ResultQuery
        GridLookUpEditSessionSociety.Properties.PopulateViewColumns()
        GridLookUpEditSessionSociety.Properties.NullText = "(none)"
        GridLookUpEditSessionSociety.Properties.ValueMember = _aMetaQuery.ResultQuery.Columns("SocietyId").ToString
        GridLookUpEditSessionSociety.Properties.PopupFormSize = New Size(500, 300)
        GridLookUpEditSessionSociety.Properties.DisplayMember = _aMetaQuery.ResultQuery.Columns("SocietyName").ToString
        GridLookUpEditSessionSociety.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit
        GridLookUpEditSessionSociety.Properties.View.Columns("SocietyId").Visible = False
        ' Select the good ROW in ComboBox
        If Guid.TryParse(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_SESSIONSOCIETY).Item("OptionValue").ToString, aGUID) Then
            GridLookUpEditSessionSociety.EditValue = aGUID
        End If



        '
        ' Polulate Description
        '
        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DESCRIPTION).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_Description = Guid.NewGuid()
        Else
            PersonOptionID_Description = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DESCRIPTION).Item("PersonOptionID"), Guid)
        End If

        RadioGroupDescription.EditValue = _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DESCRIPTION).Item("OptionValue")

        '
        ' Polulate Language
        '

        _aMetaQuery = CommonExt.MetaQuery.GetMetaQueryByName(Query_Language)
        _aMetaQuery.FillResultQuery()
        GridLookUpEditLng.Properties.DataSource = _aMetaQuery.ResultQuery
        GridLookUpEditLng.Properties.PopulateViewColumns()
        GridLookUpEditLng.Properties.NullText = "(none)"
        GridLookUpEditLng.Properties.ValueMember = _aMetaQuery.ResultQuery.Columns("StringId").ToString
        GridLookUpEditLng.Properties.PopupFormSize = New Size(500, 300)
        GridLookUpEditLng.Properties.DisplayMember = _aMetaQuery.ResultQuery.Columns("DefaultString").ToString
        GridLookUpEditLng.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit
        GridLookUpEditLng.Properties.View.Columns("StringId").Visible = False
        ' Select the good ROW in ComboBox
        GridLookUpEditLng.EditValue = New Guid(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_LANGUAGE).Item("OptionValue").ToString)

        '
        ' Polulate DecimalSeparator
        '
        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DECIMALSEPARATOR).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_DecimalSeparator = Guid.NewGuid()
        Else
            PersonOptionID_DecimalSeparator = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DECIMALSEPARATOR).Item("PersonOptionID"), Guid)
        End If

        TextEditDecimalSeparator.Text = ActiveFramework.CommonExt.Base.AppOption.DecimalSeparator

        '
        ' Polulate ThousandsSeparator
        '
        'détermine si c'est un nouveau enregistrement pour créer un nouveau GUID oubien un travail avec le guid du MetaUserOption
        If _dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_THOUSANDSEPARATOR).Item("PersonOptionID").ToString.Length = 0 Then
            PersonOptionID_ThousandsSeparator = Guid.NewGuid()
        Else
            PersonOptionID_ThousandsSeparator = CType(_dataTableLocal.Rows.Find(ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_THOUSANDSEPARATOR).Item("PersonOptionID"), Guid)
        End If

        TextEditThousandsSeparator.Text = ActiveFramework.CommonExt.Base.AppOption.ThousandsSeparator

    End Sub

    Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click

        '
        ' SAVE Default Society
        '
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command

            If Not IsNothing(GridLookUpEditDefaultSociety.EditValue) Then
                Guid.TryParse(GridLookUpEditDefaultSociety.EditValue.ToString, ActiveFramework.CommonExt.Base.AppOption.DefaultSociety)

                command.CommandText = "bsp_MetaUserOptions_Save"
                command.CommandType = CommandType.StoredProcedure
                command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_DefaultSociety)
                command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
                command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DEFAULTSOCIETY)

                'Récupère la valeur du guid du combobox sélectionnée
                command.Parameters.AddWithValue("@OptionValue", CType(GridLookUpEditDefaultSociety, GridLookUpEdit).EditValue.ToString)
                command.Parameters.AddWithValue("@PrecedenceOrder", 0)
                command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
                command.Parameters.AddWithValue("@SPResult", 0)

                command.ExecuteNonQuery()
            End If
        End Using

        '
        ' SAVE Session Society
        '
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command

            If Not IsNothing(GridLookUpEditSessionSociety.EditValue) Then

                Guid.TryParse(GridLookUpEditSessionSociety.EditValue.ToString, ActiveFramework.CommonExt.Base.AppOption.SessionSociety)

                command.CommandText = "bsp_MetaUserOptions_Save"
                command.CommandType = CommandType.StoredProcedure
                command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_SessionSociety)
                command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
                command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_SESSIONSOCIETY)

                'Récupère la valeur du guid du combobox sélectionnée
                command.Parameters.AddWithValue("@OptionValue", CType(GridLookUpEditSessionSociety, GridLookUpEdit).EditValue.ToString)
                command.Parameters.AddWithValue("@PrecedenceOrder", 0)
                command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
                command.Parameters.AddWithValue("@SPResult", 0)
                command.ExecuteNonQuery()

            End If

        End Using

        '
        ' SAVE Primary Alternate Descripton
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command

            command.CommandText = "bsp_MetaUserOptions_Save"
            command.CommandType = CommandType.StoredProcedure

            command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_Description)
            command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
            command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DESCRIPTION)
            command.Parameters.AddWithValue("@OptionValue", RadioGroupDescription.EditValue.ToString)
            command.Parameters.AddWithValue("@PrecedenceOrder", 0)
            command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
            command.Parameters.AddWithValue("@SPResult", 0)

            command.ExecuteNonQuery()
        End Using

        '
        ' SAVE Language
        '
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command



            command.CommandText = "bsp_MetaUserOptions_Save"
            command.CommandType = CommandType.StoredProcedure

            command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_Language)
            command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
            command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_LANGUAGE)
            'Récupère la valeur du guid du combobox sélectionnée
            command.Parameters.AddWithValue("@OptionValue", CType(GridLookUpEditLng, GridLookUpEdit).EditValue.ToString)
            command.Parameters.AddWithValue("@PrecedenceOrder", 0)
            command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
            command.Parameters.AddWithValue("@SPResult", 0)

            'outstanding : avoir une class qui list les parametres avec les valeurs style Console.writeLine( listparameters(command.Parameters))
            ' @PersonOptionID = 'EF0917F0-CF05-4DAD-9D15-B2F8DB9BF41A'... etc
            'pour faire un cut and paste ds SQL..ou troubleshooter
            'B.Desjardins
            command.ExecuteNonQuery()
        End Using

        '
        ' SAVE DecimalSeparator
        '
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command

            ActiveFramework.CommonExt.Base.AppOption.DecimalSeparator = TextEditDecimalSeparator.Text

            command.CommandText = "bsp_MetaUserOptions_Save"
            command.CommandType = CommandType.StoredProcedure

            command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_DecimalSeparator)
            command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
            command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_DECIMALSEPARATOR)
            'Récupère la valeur du guid du combobox sélectionnée
            command.Parameters.AddWithValue("@OptionValue", ActiveFramework.CommonExt.Base.AppOption.DecimalSeparator)
            command.Parameters.AddWithValue("@PrecedenceOrder", 0)
            command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
            command.Parameters.AddWithValue("@SPResult", 0)

            command.ExecuteNonQuery()
        End Using

        '
        ' SAVE ThousandsSeparator
        '
        Using command As SqlClient.SqlCommand = CommonExt.Base.Connection.Command

            ActiveFramework.CommonExt.Base.AppOption.ThousandsSeparator = TextEditThousandsSeparator.Text

            command.CommandText = "bsp_MetaUserOptions_Save"
            command.CommandType = CommandType.StoredProcedure

            command.Parameters.AddWithValue("@PersonOptionID", PersonOptionID_ThousandsSeparator)
            command.Parameters.AddWithValue("@UserID_FK", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserID)
            command.Parameters.AddWithValue("@AppOptionId_FK", ActiveFramework.CommonExt.Base.IdRepository.META_METAAPPLICATIONOPTIONS_THOUSANDSEPARATOR)
            'Récupère la valeur du guid du combobox sélectionnée
            command.Parameters.AddWithValue("@OptionValue", ActiveFramework.CommonExt.Base.AppOption.ThousandsSeparator)
            command.Parameters.AddWithValue("@PrecedenceOrder", 0)
            command.Parameters.AddWithValue("@UserName", SCIEF.ActiveFramework.CommonExt.Base.AppManager.UserName)
            command.Parameters.AddWithValue("@SPResult", 0)

            command.ExecuteNonQuery()
        End Using

        '
        '

        ResetCache()
        '     Me.Close()
        Dim aculture As String = AppManager.ApplicationOption.Culture
        Thread.CurrentThread.CurrentCulture = New CultureInfo(aculture)
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(aculture)
        AppOption.GetSeparator()
    End Sub

    Private Sub ResetCache()
        AppManager.ResetCache()
    End Sub


    Private Sub CCButton_Click(sender As System.Object, e As System.EventArgs) Handles CCButton.Click
        Try
            ResetCache()
            MessageWindow.ShowMessage("Reset Cache Successful", MsgBoxStyle.Information)
        Catch ex As Exception
            MessageWindow.ShowMessage(ex)
        End Try
    End Sub


    'OutStandingIssue: Dans l'onglet SysAdmin. faire le recette de cache aussi. Ajouter un Cheked Box que si cheked on le fait. aleblanc - 2011-06-20 



    Private Sub RefreshSecurity_Click(sender As System.Object, e As System.EventArgs) Handles RefreshSecurity.Click
        'Me.Cursor = Cursors.WaitCursor
        Dim waitWindow As DevExpress.Utils.WaitDialogForm
        waitWindow = New DevExpress.Utils.WaitDialogForm(DeskTopManager.GetMessage("MES-000009"), DeskTopManager.GetMessage("MES-000010"))
        waitWindow.LookAndFeel.SkinName = "Blue"
        waitWindow.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin
        waitWindow.LookAndFeel.UseDefaultLookAndFeel = False
        waitWindow.LookAndFeel.UseWindowsXPTheme = False
        waitWindow.Show()
        SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.GenerateAllSecurity(AppManager.UserID, AppManager.ApplicationOption.LanguageId)
        SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.SaveSecurityProfile(AppManager.UserID)
        SystemBoxSDK.PL.MetaSDK.SecurityProfiler_PL.WriteSecurityProfile(DeskTopManager.SecurityFileNameUserColumnSecurity, DeskTopManager.SecurityFileNameDataFieldSecurity, DeskTopManager.SecurityFileNameDataSubjectSecurity, DeskTopManager.SecurityFileNameSiteSecurity, DeskTopManager.SecurityFileNameSocietySecurity, DeskTopManager.SecurityFileNameGroupListSecurity)
        DeskTopManager.GetSecurityProfile()
        waitWindow.Close()

        'Me.Cursor = Cursors.Default
    End Sub

    Private Sub SimpleButtonCopyTo_Click_1(sender As System.Object, e As System.EventArgs) Handles SimpleButtonCopyTo.Click
        Dim waitWindow As DevExpress.Utils.WaitDialogForm
        Dim CopyResult As Boolean = False

        waitWindow = New DevExpress.Utils.WaitDialogForm("Un Instant svp", "Copie des fichiers...")
        waitWindow.LookAndFeel.SkinName = "Blue"
        waitWindow.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin
        waitWindow.LookAndFeel.UseDefaultLookAndFeel = False
        waitWindow.LookAndFeel.UseWindowsXPTheme = False

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("UserColumnSecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameUserColumnSecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        '    CopyResult = True
        'Else
        '    CopyResult = False
        'End If

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("DataFieldSecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameDataFieldSecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        'CopyResult = True
        'Else
        'CopyResult = False
        'End If

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("DataSubjectSecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameDataSubjectSecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        'CopyResult = True
        'Else
        'CopyResult = False
        'End If

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("SiteSecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameSiteSecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        'CopyResult = True
        'Else
        'CopyResult = False
        'End If

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("SocietySecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameSocietySecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        'CopyResult = True
        'Else
        'CopyResult = False
        'End If

        TextEditNewFIleName.Text = System.IO.Path.Combine(DeskTopManager.ApplicationDataFolder, CommonExt.Utils.FileExt.EncodedFileName("GroupListSecurity" + TextEditUserName.Text.ToLower + TextEditServer.Text.ToLower + TextEditDB.Text.ToLower))
        'If Not System.IO.File.Exists(TextEditNewFIleName.Text) Then
        System.IO.File.Copy(DeskTopManager.SecurityFileNameSocietySecurity, TextEditNewFIleName.Text, True)
        System.IO.File.SetLastWriteTime(TextEditNewFIleName.Text, DateTime.Now)
        'CopyResult = True
        'Else
        'CopyResult = False
        'End If

        waitWindow.Close()

        'If CopyResult Then
        MessageWindow.ShowMessage("Copy of new security file done.", MsgBoxStyle.Information)
        'Else
        'MessageWindow.ShowMessage("File already exists in your folder.", MsgBoxStyle.Information)
        'End If
    End Sub



    Private Sub AppOptionForm_Load(sender As Object, e As EventArgs) Handles Me.Load

    End Sub
End Class

